import MoleCtrl from "./MoleCtrl";
import HummerCtrl from "./HummerCtrl";

export default class Gameroot extends Laya.Script {

    constructor() { 
        super(); 
        // 更多参数说明请访问: https://ldc2.layabox.com/doc/?nav=zh-as-2-4-0
    }
    onAwake(){
        Laya.Scene3D.load("res/scenc/LayaScene_game/Conventional/game.ls",Laya.Handler.create(this,this.onLoadSceneFinish))
    }
    onLoadSceneFinish(loadScene){
        loadScene.zOrder=-1;
        Laya.stage.addChild(loadScene)
        var moles= loadScene.getChildByName("Moles");
        for(var i=0;i<moles.numChildren;i++){
            moles.getChildAt(i).getChildAt(0).addComponent(MoleCtrl);
        }
        var effect=loadScene.getChildByName("Explosion");
        var effectPrefab= Laya.Sprite3D.instantiate(effect);
        effect.active=false;
        //获取摄像机
        var camera=loadScene.getChildByName("Main Camera")
        loadScene.getChildByName("Hummer").addComponent(HummerCtrl).Init(camera,loadScene,effectPrefab);

    }
}